﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace Xejen.Logger.Log4Net
{
    /// <summary>
    /// Log4Net日志工厂
    /// </summary>
    public class Log4NetLoggerFactory : ILoggerFactory
    {
        private readonly Log4NetProviderOptions _options;

        /// <inheritdoc cref="Log4NetLoggerFactory"/>
        public Log4NetLoggerFactory()
        {
            _options = new Log4NetProviderOptions(); // 使用默认选项
        }

        /// <summary>
        /// <inheritdoc cref="Log4NetLoggerFactory"/>
        /// </summary>
        /// <param name="options"></param>
        public Log4NetLoggerFactory(Log4NetProviderOptions options)
        {
            _options = options; // 使用自定义选项
        }

        /// <summary>
        /// 添加Provider
        /// </summary>
        /// <param name="provider"></param>
        public void AddProvider(ILoggerProvider provider)
        {

        }

        /// <summary>
        /// 创建日志对象
        /// </summary>
        /// <param name="categoryName"></param>
        /// <returns></returns>
        public ILogger CreateLogger(string categoryName)
        {
            return new Xejen.Logger.Log4Net.Log4NetLogger(categoryName, _options);
        }

        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {

        }
    }
}
